#include<bits/stdc++.h>
using namespace std;
const int N=1.3e7+7;
int r,c,n,p[N],q[N],top,tot,ex_dis[N],s,t;
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,1,-1,1,-1},dyy[8]={1,-1,0,0,1,1,-1,-1};
vector<int>dis[3010],vis[3010];
string ss[3010];
int uu[N],vv[N],tl;
void extand_for_0(){
    tl=0;
    while(top<=tot){
        int g=p[top],h=q[top];
        uu[++tl]=g;vv[tl]=h;
        top++;
        for(int i=0;i<4;i++){
            int gg=g+dx[i],hh=h+dy[i];
            if(gg<0||gg>=r||hh<0||hh>=c)
                continue;
            if(ss[gg][hh]=='.'&&dis[gg][hh]==N){
                dis[gg][hh]=dis[g][h];
                p[++tot]=gg;
                q[tot]=hh;
            }
        }
    }
    top=1;
    tot=tl;
    for(int i=1;i<=tl;i++){
        p[i]=uu[i];
        q[i]=vv[i];
    }
    return;
}
void extand_for_1(){
    int yu=tot,ds=dis[p[top]][q[top]];tl=0;
    for(int i=top;i<=yu;i++){
        for(int j=0;j<4;j++){
            int pp=p[i]+dx[j],qq=q[i]+dy[j];
            if(pp<0||pp>=r||qq<0||qq>=c)
                continue;
            if(dis[pp][qq]>=ds&&!vis[pp][qq]){
                p[++tot]=pp;
                q[tot]=qq;
                if(dis[pp][qq]>ds+1){
                    dis[pp][qq]=ds+1;
                    uu[++tl]=pp;
                    vv[tl]=qq;
                }
                vis[pp][qq]=1;
            }
        }
    }
    for(int i=top;i<=tot;i++)
        ex_dis[i]=0;
    while(top<=tot){
        if(ex_dis[top]>=n-1){
            top++;
            continue;
        }
        int xx=p[top],yy=q[top],nw=ex_dis[top];
        top++;
        for(int i=0;i<8;i++){
            int gg=xx+dxx[i],hh=yy+dyy[i];
            if(gg<0||gg>=r||hh<0||hh>=c)
                continue;
            if(dis[gg][hh]>ds+1){
                dis[gg][hh]=ds+1;
                uu[++tl]=gg;
                vv[tl]=hh;
                p[++tot]=gg;
                q[tot]=hh;
                ex_dis[tot]=nw+1;
            }
        }
    }
    top=1;
    tot=tl;
    for(int i=1;i<=tl;i++){
        p[i]=uu[i];
        q[i]=vv[i];
    }
    return;
}
signed main(){
    freopen("stamp.in","r",stdin);
    freopen("stamp.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cin>>r>>c>>n;
    for(int i=0;i<r;i++){
        dis[i].resize(c);
        vis[i].resize(c);
        for(auto &h:dis[i])
            h=N;
        for(auto &h:vis[i])
            h=0;
    }
    cin>>s>>t;
    s--;
    t--;
    dis[s][t]=0;
    p[1]=s;
    q[top=tot=1]=t;
    cin>>s>>t;
    s--;
    t--;
    for(int i=0;i<r;i++)
        cin>>ss[i];
    while(dis[s][t]==N){
        extand_for_0();
        extand_for_1();
    }
    cout<<dis[s][t]<<"\n";
    return 0;
}
